﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Tour.BLL;
using Tour.DAL;

public partial class Controls_Tourist_Tourim : VST.Controls.BaseLCGUserControl
{
    public int? TourTypeId { get; set; }
    public string TourTypeTextId { get; set; }
    public bool? IsVisible { get; set; }
    public bool? IsPromotion { get; set; }
    public bool? IsHot { get; set; }
    public bool? IsHome { get; set; }
    public string Expression { get; set; }
    public string Collate { get; set; }
    public static int PageSize = 4;
    public int PageIndex { get; set; }
    protected void Page_Load(object sender, EventArgs e)
    {
        GetPropertyFromQueryString();
        LoadData(); 
        LoadData1();
    }
    void GetPropertyFromQueryString()
    {
        TourTypeId = CommonHelper.QueryStringInt("TourTypeId", null);
        IsVisible = CommonHelper.QueryStringBoolNullable("IsVisible");
        IsHome = CommonHelper.QueryStringBoolNullable("IsHome");
        IsHot = CommonHelper.QueryStringBoolNullable("IsHot");
        IsPromotion = CommonHelper.QueryStringBoolNullable("IsPromotion");
        Expression = CommonHelper.QueryString(Expression, "CreatedDate");
        Collate = CommonHelper.QueryString("Collate", "DESC");
        TourTypeTextId = CommonHelper.QueryString("TourTypeTextId");
        PageIndex = CommonHelper.QueryStringInt("PageIndex", 1);

    }

    void LoadData()
    {
        int TotalRow = 0;
        // TourTypeId = int.Parse(GetLocaleResourceString("Module.Home.TourNoiDiaID"));     
        //rpt.DataSource = TblTourManager.CreateInstant().SelectTblTourBy(null, TourTypeId, "", true, true, true, true, PageSize, PageIndex, out TotalRow, Expression, Collate);
        //rpt.DataSource = TblTourManager.CreateInstant().tr_SelectTblTourByTourTypeAllChild(null,TourTypeTextId, null, null, null, null, PageSize, PageIndex, out TotalRow, Expression, Collate);
        rpt.DataSource = TblTourManager.CreateInstant().tr_SelectTblTourByTourTypeAllChild(null, "tour-noi-dia", null, null, null, null, PageSize, PageIndex, out TotalRow, Expression, Collate);
        rpt.DataBind();
        //smartPager.PageSize = PageSize;
        //smartPager.QueryStringKey = "PageIndex";
        //smartPager.RowCount = TotalRow;
        //smartPager.UrlFormatString = string.Format("Default.aspx?TourTypeId={0}&IsVisible={1}&IsHome={2}&IsHot={3}&IsPromotion={4}&Expression={5}&Collate={6}", TourTypeId, CommonHelper.BoolToIntString(IsVisible)
        //    , CommonHelper.BoolToIntString(IsHome), CommonHelper.BoolToIntString(IsHot), CommonHelper.BoolToIntString(IsPromotion), Expression, Collate) + "&PageIndex={0}";
        //smartPager.Visible = TotalRow > PageSize;        
    }
    void LoadData1()
    {
        int TotalRow = 0;
        //TourTypeId = int.Parse(GetLocaleResourceString("Module.Home.TourQuocTeID "));
        //Trace.Warn("TourTypeId:" + TourTypeId);
        //rpt.DataSource = TblTourManager.CreateInstant().SelectTblTourBy(null, TourTypeId, "", true, true, true, true, PageSize, PageIndex, out TotalRow, Expression, Collate);
        //rptQuocTe.DataSource = TblTourManager.CreateInstant().tr_SelectTblTourByTourTypeAllChild(TourTypeId, "", null, null, null, null, PageSize, PageIndex, out TotalRow, Expression, Collate);
        rptQuocTe.DataSource = TblTourManager.CreateInstant().tr_SelectTblTourByTourTypeAllChild(null, "tour-quoc-te", null, null, null, null, PageSize, PageIndex, out TotalRow, Expression, Collate);
        rptQuocTe.DataBind();
        //smartPager1.PageSize = PageSize;
        //smartPager1.QueryStringKey = "PageIndex";
        //smartPager1.RowCount = TotalRow;
        //smartPager1.UrlFormatString = string.Format("Default.aspx?TourTypeId={0}&IsVisible={1}&IsHome={2}&IsHot={3}&IsPromotion={4}&Expression={5}&Collate={6}", TourTypeId, CommonHelper.BoolToIntString(IsVisible)
        //    , CommonHelper.BoolToIntString(IsHome), CommonHelper.BoolToIntString(IsHot), CommonHelper.BoolToIntString(IsPromotion), Expression, Collate) + "&PageIndex={0}";
        //smartPager1.Visible = TotalRow > PageSize;        
    }
}